package com.adv.ems.controller.client;

import com.adv.ems.constants.SystemConst;
import com.adv.ems.model.dto.APIRequest;
import com.adv.ems.model.dto.APIResponse;
import com.adv.ems.model.param.*;
import com.adv.ems.model.vo.*;
import com.adv.ems.service.IndexService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/ems/client/index")
public class IndexController {
    @Resource
    IndexService indexService;

    @PostMapping("/energy/list")
    public APIResponse<IndexEnergyInfoVO> energyList(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage) {
        return APIResponse.<IndexEnergyInfoVO>build().content(indexService.IndexEnergyInfoVO(acceptLanguage));
    }

    @PostMapping("/map/subject/list")
    public APIResponse<IndexEnergyMapSubjectVO> mapSubjectList(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                                               @RequestBody APIRequest<IndexEnergyMapSubjectParam> request) {
        return APIResponse.<IndexEnergyMapSubjectVO>build().content(indexService.mapSubjectList(request.getContent(), acceptLanguage));
    }
    @PostMapping("/energy/calendar")
    public APIResponse<IndexEnergyCalendarVO> energyCalendar(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                                             @RequestBody APIRequest<IndexEnergyCalendarParam> request) {
        return APIResponse.<IndexEnergyCalendarVO>build().content(indexService.energyCalendar(request.getContent(), acceptLanguage));
    }

    @PostMapping("/energy/time/trend")
    public APIResponse<IndexEnergyTimeTrendVO> energyTimeTrend(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                                               @RequestBody APIRequest<IndexEnergyTimeTrendParam> request) {
        return APIResponse.<IndexEnergyTimeTrendVO>build().content(indexService.energyTimeTrend(request.getContent(), acceptLanguage));
    }

    @PostMapping("/item/compare")
    public APIResponse<IndexCompareVO> itemCompare(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                                   @RequestBody APIRequest<IndexCompareParam> request) {
        return APIResponse.<IndexCompareVO>build().content(indexService.itemCompare(request.getContent(), acceptLanguage));
    }

    @PostMapping("/energy/compare")
    public APIResponse<IndexCompareVO> energyCompare(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                                                   @RequestBody APIRequest<IndexCompareParam> request) {
        return APIResponse.<IndexCompareVO>build().content(indexService.energyCompare(request.getContent(), acceptLanguage));
    }

    @PostMapping("/energy/year/summarize")
    public APIResponse<IndexEnergyYearSummarizeVO> energyYearSummarize(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                                     @RequestBody APIRequest<IndexEnergyYearSummarizeParam> request) {
        return APIResponse.<IndexEnergyYearSummarizeVO>build().content(indexService.energyYearSummarize(request.getContent(), acceptLanguage));
    }

    @PostMapping("/energy/time/compare")
    public APIResponse<IndexEnergyTimeCompareVO> energyTimeCompare(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                                                   @RequestBody APIRequest<IndexEnergyTimeCompareParam> request) {
        return APIResponse.<IndexEnergyTimeCompareVO>build().content(indexService.energyTimeCompare(request.getContent(), acceptLanguage));
    }
}
